#ifndef USER_H
#define USER_H

#include <string>
#include <vector>

class User
{
private:
    std::string username;
    int socket_fd;

public:
    User(const std::string& username,int socket_fd):username(username),socket_fd(socket_fd){}
    
    std::string getUsername() const 
    {
        return username;
    }

    int getSocketFd() const
    {
        return socket_fd;
    }
};

//用户管理类
class UserManager
{
private:
    std::vector<User> users;

public:
    void addUser(const User& user)
    {
        users.push_back(user);
    }

    void removeUser(int socket_fd)
    {
        for (auto it = users.begin(); it != users.end(); ++it)
        {
            if (it->getSocketFd() == socket_fd)
            {
                users.erase(it);
                break;
            }
            
        }
        
    }

    std::vector<User> getUsers() const
    {
        return users;
    }
};

#endif